<?php

namespace App\Http\Controllers\user;

use App\Dao\PersonalDao;
use App\Exceptions\SysExceptions;
use App\Services\Code;
use SimpleSoftwareIO\QrCode\Facades\QrCode;

class PersonalController extends BaseController
{
    /**
     * @desc 用户升级匹配用户
     * @return array
     * @throws SysExceptions
     */
    public function users_upgrade(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        return Code::message('',200,PersonalDao::users_upgrade($params));
    }

    public function users_upgrade_confirm(): array
    {
        $params = array_merge(request()->all(),[
            'user_id'=>getUserToken()
        ]);
        return Code::message('',200,PersonalDao::users_upgrade_confirm($params));
    }

    public function user_urgrade_lists(): array
    {
        $params = array_merge(request()->all(),[
            'b_user_id'=>getUserToken()
        ]);
        return Code::message('',200,PersonalDao::user_urgrade_lists($params));
    }

    public function agree_user_urgrade(): array
    {
        $params = array_merge(request()->all(),[
            'b_user_id'=>getUserToken()
        ]);
        PersonalDao::agree_user_urgrade($params);
        return Code::message('',200);
    }

    public function url_img(): array
    {

//        echo 'http://'.$_SERVER['HTTP_HOST'].'/erji/pagesHome/login/register?spread_id='.request('user_id');exit;
        QrCode::size(200)->generate('http://'.$_SERVER['HTTP_HOST'].'/h5/pagesHome/login/register?spread_id='.request('user_id'),public_path('/uer_code_'.request('user_id').'.svg'));
        return Code::message('',200,'http://'.$_SERVER['HTTP_HOST'].'/uer_code_'.request('user_id').'.svg');
    }


    
}
